package com.ld.controller;

import com.ld.doamin.Menu;
import com.ld.service.IMenuService;
import com.ld.basic.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    private IMenuService service;
    @GetMapping
    public AjaxResult getMenuTree(Long empId) {
        try {
            List<Menu> menus= service.getMenuTree(empId);
            return AjaxResult.me().setData(menus);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setSuccess(false).setMsg("查询失败");
        }
    }
}
